﻿using MediatR;
using Microsoft.OpenApi.Models;
using SheepStorage.API.Application.Command.SheepMomDeliveryCommand;
using SheepStorage.API.Application.Command.SheepMomPergnantCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMomDeliveryHandler
{
    public class SheepMomDeliveryUpdateCommandHandler : IRequestHandler<SheepMomDeliveryUpdateCommand, Results<int>>
    {
        private readonly ISheepMomDeliveryService SheepMomDeliveryService;
        public SheepMomDeliveryUpdateCommandHandler(ISheepMomDeliveryService SheepMomDeliveryService)
        {
            this.SheepMomDeliveryService = SheepMomDeliveryService;
        }
        public async Task<Results<int>> Handle(SheepMomDeliveryUpdateCommand request, CancellationToken cancellationToken)
        {
            var del = new SheepMomDelivery()
            {
                BuildingManagementId = request.BuildingManagementId,
                DeliveryBuilding = request.DeliveryBuilding,
                DeliveryDieAvgWeight = request.DeliveryDieAvgWeight,
                DeliveryDieSumWeight = request.DeliveryDieSumWeight,
                DeliveryFatSheep = request.DeliveryFatSheep,
                DeliveryField = request.DeliveryField,
                DeliveryHealth = request.DeliveryHealth,
                DeliveryLivingAvgWeight = request.DeliveryLivingAvgWeight,
                DeliveryLivingSumWeight = request.DeliveryLivingSumWeight,
                DeliveryMalformation = request.DeliveryMalformation,
                DeliveryMonster = request.DeliveryMonster,
                DeliveryMummy = request.DeliveryMummy,
                DeliveryPrincipal = request.DeliveryPrincipal,
                DeliverySex = request.DeliverySex,
                DeliverySlowId = request.DeliverySlowId,
                DeliveryStillbirth = request.DeliveryStillbirth,
                DeliveryTotalDie = request.DeliveryTotalDie,
                DeliveryTotalLiving = request.DeliveryTotalLiving,
                DeliveryTotalWeight = request.DeliveryTotalWeight,
                DeliveryWeak = request.DeliveryWeak,
                MomDeliveryComplexity = request.MomDeliveryComplexity,
                MomDeliveryCount = request.MomDeliveryCount,
                MomDeliveryDate = request.MomDeliveryDate,
                MomDeliveryGestation = request.MomDeliveryGestation,
                MomDeliveryId = request.MomDeliveryId,
                MomDeliveryLactation = request.MomDeliveryLactation,
                MomDeliveryMastitis = request.MomDeliveryMastitis,
                MomDeliveryMaternity = request.MomDeliveryMaternity,
                OverBit = request.OverBit,
                SheepFieldId = request.SheepFieldId,

            };

            var result = await SheepMomDeliveryService.UpdateSheepMomDelivery(del);
            return Results<int>.DataResult(result);
        }
    }
}
